package com.rxkj.mapper;

import com.rxkj.entity.gnss.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface GnssDataMapper {

    //查询位移数据条数
    Long getTotalRows(@Param("qg") QueryGnssVO queryGnss);

    //查询位移数据
    List<GnssDataVO> getGnssDataPage(@Param("start") int start, @Param("end") int end, @Param("qg") QueryGnssVO queryGnss);

    //获取水库信息
    List<HiddenPointVO> getHiddenPointByAreaCode(@Param("areaCode") String areaCode);

    //获取断面信息
    List<SectionVO> getSectionByAreaCode(@Param("areaCode") String areaCode);

    //获取设备信息
    List<GnssDeviceVO> getDeviceByAreaCode(@Param("areaCode") String areaCode);

    Long initDevDataTotalRows(@Param("areaCode") String areaCode, @Param("deviceName")String deviceName);

    List<DeviceIDVO> getCurrentPageDevIds(@Param("areaCode") String areaCode, @Param("start") int start, @Param("end") int end, @Param("deviceName")String deviceName);

    GnssDataVO getGnssDataByDevid(@Param("devid") String devid);

    @Select("SELECT COUNT(*) FROM `earth_disaster`.surf_devicedata WHERE DEVICEID = #{deviceId} AND DACTIME BETWEEN #{startTime} AND #{endTime}")
    @ResultType(Long.class)
    Long getDevDataTotalRows(QueryGnssVO queryGnss);

    @Select("SELECT * FROM `earth_disaster`.surf_devicedata WHERE DEVICEID = #{qg.deviceId} AND DACTIME BETWEEN #{qg.startTime} AND #{qg.endTime} ORDER BY DACTIME DESC LIMIT #{start}, #{end}")
    List<GnssDataVO> getDevDataPageByDeviceid(@Param("start") int start, @Param("end") int end, @Param("qg") QueryGnssVO queryGnss);

    @Select("SELECT * FROM `earth_disaster`.surf_devicedata WHERE DEVICEID = #{deviceId} AND DACTIME BETWEEN #{startTime} AND #{endTime} ORDER BY DACTIME ASC")
    @ResultType(GnssDataVO.class)
    List<GnssDataVO> getGnssChartDataByDveId(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("deviceId") String deviceId);
}
